#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
#include "medecin.h"
#include "infirmier.h"
#include "patient.h"


void on_button1_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window1;
                GtkWidget *window2;
                window1 = lookup_widget(objet_graphique,"window1");
                gtk_widget_hide(window1);
                window2 = create_window2();
		gtk_widget_show(window2);

}


void on_button3_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                
                GtkWidget *window4;
                GtkWidget *window2;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void on_button6_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

}


void on_button5_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window1;
                GtkWidget *window2;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window1 = create_window1();
		gtk_widget_show(window1);
}


void on_button2_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window3;
                GtkWidget *window2;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window3 = create_window3();
		gtk_widget_show(window3);
}


void on_button4_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window5;
                GtkWidget *window2;
                window2 = lookup_widget(objet_graphique,"window2");
                gtk_widget_hide(window2);
                window5 = create_window5();
		gtk_widget_show(window5);
}


void on_button10_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

}


void on_button9_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
char aux[50];
                GtkWidget *window15;
                GtkWidget *window3;
 GtkWidget label45;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window15 = create_window15();
		gtk_widget_show(window15);
label45= lookup_widget(objet_graphique, "label45");
afficher_liste_medecin("medecin.txt",M);
sprintf(aux, "%s    %s     %d ",  P.nom,P.prenom, P.age);

	gtk_label_set_text(GTK_LABEL(label5), aux);

}


void on_button8_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window9;
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");;
                gtk_widget_hide(window3);
                window9 = create_window9();
		gtk_widget_show(window9);
}


void on_button7_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window6;
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window6 = create_window6();
		gtk_widget_show(window6);
}


void on_button12_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

}


void on_button11_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
               // Medecin M;
                GtkWidget *window18;
                GtkWidget *window3;
                //GtkWidget *label53;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window18 = create_window18();
		gtk_widget_show(window18);
               // label53= lookup_widget(objet_graphique, "label53");
               // init_liste_medecin("medecin.txt",&M);

}


void on_button13_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window2;
                GtkWidget *window3;
                window3 = lookup_widget(objet_graphique,"window3");
                gtk_widget_hide(window3);
                window2 = create_window2();
		gtk_widget_show(window2);
}


void on_button14_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window7;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window7 = create_window7();
		gtk_widget_show(window7);
}


void on_button15_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window10;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window10 = create_window10();
		gtk_widget_show(window10);
}


void on_button16_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window16;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window16 = create_window16();
		gtk_widget_show(window16);

}


void on_button17_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

}


void on_button18_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

}


void on_button19_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window19;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window19 = create_window19();
		gtk_widget_show(window19);

}


void on_button20_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window2;
                GtkWidget *window4;
                window4 = lookup_widget(objet_graphique,"window4");
                gtk_widget_hide(window4);
                window2 = create_window2();
		gtk_widget_show(window2);
}

                                                           /*ENREGISTRER MEDECIN*/
void on_button28_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
        Medecin M;
        int n;
        long int id_medecin=10001;
        GtkWidget *entry3;
	GtkWidget *entry4;
	GtkWidget *entry5;
        GtkWidget *entry6;
	GtkWidget *entry7;
	

	entry3 = lookup_widget(objet_graphique, "entry3");
	entry4 = lookup_widget(objet_graphique, "entry4");
	entry5 = lookup_widget(objet_graphique, "entry5");
        entry6 = lookup_widget(objet_graphique, "entry6");
	entry7 = lookup_widget(objet_graphique, "entry7");

strcpy(M.nom, gtk_entry_get_text(GTK_ENTRY(entry3)));
strcpy(M.prenom, gtk_entry_get_text(GTK_ENTRY(entry4)));
M.tel = atoi(gtk_entry_get_text(GTK_ENTRY(entry5)));
M.cin = atoi(gtk_entry_get_text(GTK_ENTRY(entry6)));
M.age = atoi(gtk_entry_get_text(GTK_ENTRY(entry7)));

        M.id_medecin=id_medecin; 
        enregistrer_medecin("medecin.txt",&M,&n);
        id_medecin=id_medecin+1;
}


void on_button29_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window3;
                GtkWidget *window6;
                window6 = lookup_widget(objet_graphique,"window6");
                gtk_widget_hide(window6);
                window3 = create_window3();
		gtk_widget_show(window3);
}

                                                                 /*ENREGISTRER INFIRMIER*/
void on_button30_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
        Infirmier I;
        int n_infirmier=0;
        long int id_infirmier=20001;
        GtkWidget *entry8;
	GtkWidget *entry9;
	GtkWidget *entry10;
        GtkWidget *entry11;
	GtkWidget *entry12;
	

	entry8 = lookup_widget(objet_graphique, "entry8");
	entry9 = lookup_widget(objet_graphique, "entry9");
	entry10 = lookup_widget(objet_graphique, "entry10");
        entry11 = lookup_widget(objet_graphique, "entry11");
	entry12 = lookup_widget(objet_graphique, "entry12");

strcpy(I.nom, gtk_entry_get_text(GTK_ENTRY(entry8)));
strcpy(I.prenom, gtk_entry_get_text(GTK_ENTRY(entry9)));
//I.tel = atoi(gtk_entry_get_text(GTK_ENTRY(entry10)));
I.cin = atoi(gtk_entry_get_text(GTK_ENTRY(entry11)));
I.age = atoi(gtk_entry_get_text(GTK_ENTRY(entry12)));

        I.id_infirmier=id_infirmier;
        enregistrer_infirmier("infirmier.txt",&I,&n_infirmier);
        id_infirmier=id_infirmier+1;
}


void on_button31_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window4;
                GtkWidget *window7;
                window7 = lookup_widget(objet_graphique,"window7");
                gtk_widget_hide(window7);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void on_button39_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

}


void on_button41_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window4;
                GtkWidget *window13;
                window13 = lookup_widget(objet_graphique,"window13");
                gtk_widget_hide(window13);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void on_button40_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

}


void on_button42_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window5;
                GtkWidget *window14;
                window14 = lookup_widget(objet_graphique,"window14");
                gtk_widget_hide(window14);
                window5 = create_window5();
		gtk_widget_show(window5);
}


void on_button43_clicked(GtkWidget *objet_graphique, gpointer user_data)
{ 
                GtkWidget *window3;
                GtkWidget *window15;
                window15 = lookup_widget(objet_graphique,"window15");
                gtk_widget_hide(window15);
                window3 = create_window3();
		gtk_widget_show(window3);

}


void on_button44_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window4;
                GtkWidget *window16;
                window16 = lookup_widget(objet_graphique,"window16");
                gtk_widget_hide(window16);
                window4 = create_window4();
		gtk_widget_show(window4);

}


void on_button46_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
 Medecin M;
                GtkWidget *window3;
                GtkWidget *window18;
GtkWidget *label53;
                window18 = lookup_widget(objet_graphique,"window18");
                gtk_widget_hide(window18);
                window3 = create_window3();
		gtk_widget_show(window3);
 label53= lookup_widget(objet_graphique, "label53");
                init_liste_medecin("medecin.txt",&M);

}


void on_button47_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window4;
                GtkWidget *window19;
                window19 = lookup_widget(objet_graphique,"window19");
                gtk_widget_hide(window19);
                window4 = create_window4();
		gtk_widget_show(window4);

}


void on_button48_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window5;
                GtkWidget *window20;
                window20 = lookup_widget(objet_graphique,"window20");
                gtk_widget_hide(window20);
                window5 = create_window5();
		gtk_widget_show(window5);

}


void on_button21_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window8;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window8 = create_window8();
		gtk_widget_show(window8);
}

void on_button22_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window11;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window11 = create_window11();
		gtk_widget_show(window11);

}
void on_button23_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window17;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window17 = create_window17();
		gtk_widget_show(window17);

}
void on_button24_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

}
void on_button25_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

}
void on_button26_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window20;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window20 = create_window20();
		gtk_widget_show(window20);

}
void on_button27_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window2;
                GtkWidget *window5;
                window5 = lookup_widget(objet_graphique,"window5");
                gtk_widget_hide(window5);
                window2 = create_window2();
		gtk_widget_show(window2);
}

void on_button45_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window5;
                GtkWidget *window17;
                window17 = lookup_widget(objet_graphique,"window17");
                gtk_widget_hide(window17);
                window5 = create_window5();
		gtk_widget_show(window5);
}


void on_button52_clicked(GtkWidget *objet_graphique, gpointer user_data)
{

                GtkWidget *window3;
                GtkWidget *window9;
                window9 = lookup_widget(objet_graphique,"window9");
                gtk_widget_hide(window9);
                window3 = create_window3();
		gtk_widget_show(window3);
}


void on_button51_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window4;
                GtkWidget *window10;
                window10 = lookup_widget(objet_graphique,"window10");
                gtk_widget_hide(window10);
                window4 = create_window4();
		gtk_widget_show(window4);
}


void on_button50_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window5;
                GtkWidget *window11;
                window11 = lookup_widget(objet_graphique,"window11");
                gtk_widget_hide(window11);
                window5 = create_window5();
		gtk_widget_show(window5);
}


void on_button49_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
gtk_main_quit();
}

void on_destroy(GtkObject *object, gpointer user_data)
{
	gtk_main_quit();
}

void
on_nouveau1_activate                   (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_ouvrir1_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_enregistrer1_activate               (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_enregistrer_sous1_activate          (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_quitter1_activate                   (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_couper1_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_copier1_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_coller1_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_supprimer1_activate                 (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on____propos1_activate                 (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_nouveau2_activate                   (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_ouvrir2_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_enregistrer2_activate               (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_enregistrer_sous2_activate          (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_quitter2_activate                   (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_couper2_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_copier2_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_coller2_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_supprimer2_activate                 (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on____propos2_activate                 (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_nouveau3_activate                   (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_ouvrir3_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_enregistrer3_activate               (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_enregistrer_sous3_activate          (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_quitter3_activate                   (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_couper3_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_copier3_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_coller3_activate                    (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on_supprimer3_activate                 (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void
on____propos3_activate                 (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{

}


void on_button33_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
                GtkWidget *window5;
                GtkWidget *window8;
                window8 = lookup_widget(objet_graphique,"window8");
                gtk_widget_hide(window8);
                window5 = create_window5();
		gtk_widget_show(window5);
}


                                                           /*ENREGISTRER PATIENT*/
void on_button32_clicked(GtkWidget *objet_graphique, gpointer user_data)
{
        Patient P;
        int n_patient;
        long int id_patient=50001;
        GtkWidget *entry13;
	GtkWidget *entry14;
	GtkWidget *entry15;
        GtkWidget *entry16;
	

	entry13 = lookup_widget(objet_graphique, "entry13");
	entry14 = lookup_widget(objet_graphique, "entry14");
	entry15 = lookup_widget(objet_graphique, "entry15");
        entry16 = lookup_widget(objet_graphique, "entry16");

strcpy(P.nom, gtk_entry_get_text(GTK_ENTRY(entry13)));
strcpy(P.prenom, gtk_entry_get_text(GTK_ENTRY(entry14)));
//P.tel = atoi(gtk_entry_get_text(GTK_ENTRY(entry5)));
P.cin = atoi(gtk_entry_get_text(GTK_ENTRY(entry15)));
P.age = atoi(gtk_entry_get_text(GTK_ENTRY(entry16)));

        P.id_patient=id_patient; 
        enregistrer_patient("patient.txt",&P,&n_patient);
        id_patient=id_patient+1;
}

